#ifndef clox_hash_table_h
#define clox_hash_table_h

#include "common.h"

// 扩容阈值 size / capacity
#define HASH_TABLE_EXTEND_THRETHOLD 0.8
#define HASH_TABLE_DEFAULT_CAPACITY 8
#define HASH_TABLE_TOMBSTONE_VAL 0x7ffc000000000000

typedef struct {
    void *key;
    void *val;
} Entry;

typedef struct {
    int capacity;
    int size;
    HashFn hash;
    CompareFn compare;
    Entry* data;
} HashTable;

void hashTableInit(HashTable* table, HashFn hash, CompareFn compare);
Entry* hashTablePut(HashTable* table, void* key, void* val);
Entry hashTableRemove(HashTable* table, void* key);
void* hashTableGet(HashTable* table, void* key);
Entry* hashTableGetEntry(HashTable* table, void* key);

#endif
